package StudyCode.summary.textfile;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class WritingFileUsingBufferedWriterClass {
	public static void main(String[] args) throws IOException {
		try {
			String newName = "www.tah1986.com";
			Path file = Paths.get("E:/Copy/test1.txt");
			try (BufferedWriter writer = Files.newBufferedWriter(file, Charset.defaultCharset(), StandardOpenOption.APPEND)) {
				writer.newLine();
				writer.write(newName, 0, newName.length());
			}
			System.out.println("使用 BufferedWriter 类写入文件成功");
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
